package com.damieoa.damieoa.controller;

import com.damieoa.damieoa.pojo.Login;
import com.damieoa.damieoa.service.LoginService;
import com.damieoa.damieoa.vo.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import java.util.UUID;

@RestController
@CrossOrigin
@Transactional
public class LoginController {

    @Autowired
    private LoginService loginService;

    //登录验证
    @PostMapping("/login")
    public SysResult Login(@RequestBody Login login){
        Login login1 = loginService.login(login);
        if (login1 != null){
            String token = UUID.randomUUID().toString().replace("-", "");
            return SysResult.success(token);
        }
        return SysResult.fail();
    }

}
